package com.xiaren.bean;

import javax.swing.*;
import javax.swing.text.Document;
import javax.swing.text.StyledDocument;

/**
 * 用于表示文件信息
 * Created by xiaren on 2016/12/23.
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 */
public class FileBean {
    private long id;
    private long parentId;
    private String name;
    private JTextPane jTextPane;
    private String password;

    public FileBean() {
    }

    public FileBean(JTextPane jTextPane) {
        this.jTextPane = jTextPane;
    }

    public FileBean(long id, JTextPane jTextPane) {
        this(jTextPane);
        this.id = id;
    }

    public FileBean(long id, long parentId, String name, JTextPane jTextPane) {
        this(id, jTextPane);
        this.parentId = parentId;
        this.name = name;
    }


    public Document getDocument() {
        return this.getjTextPane().getDocument();
    }

    public void setDocument(Document document) {
        this.getjTextPane().setDocument(document);
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getParentId() {
        return parentId;
    }

    public void setParentId(long parentId) {
        this.parentId = parentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return getjTextPane().getText();
    }

    public void setContent(String content) {
        getjTextPane().setText(content);
    }

    public StyledDocument getStyledDocument(){
        return (StyledDocument)getDocument();
    }

    public JTextPane getjTextPane() {
        return jTextPane;
    }

    public void setjTextPane(JTextPane jTextPane) {
        this.jTextPane = jTextPane;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "FileBean{" +
                "id=" + id +
                ", parentId=" + parentId +
                ", name='" + name + '\'' +
                ", content='" + jTextPane.getText() + '\'' +
                "}";
    }
}
